<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title><spring:message code="message.listForm.yiLiaoJiGou"/><spring:message code="message.jieSuan.zhiFuDan"/><spring:message code="message.jieSuan.anPeiSongQiYeFenZu"/></title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
</head>
<body class="skin-blue sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1><spring:message code="message.listForm.yiLiaoJiGou"/><spring:message code="message.jieSuan.zhiFuDanGuanLi"/></h1>
         <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.jieSuan.zhiFuDanGuanLi"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.listForm.yiLiaoJiGou"/><spring:message code="message.jieSuan.zhiFuDanGuanLi"/></a></li>
        </ol>
    </section>
    
    <section class="content">
        <div class=" box box-success ">
             <div class="box-body">
                <div class=" form-inline">
                    <div class="form-group form-group-xs">
                        <label for="searchrecpAddr"><spring:message code="message.model.peiSongQiYe"/>：</label>
                        <input class="form-control" type="text" id="compName" name="compName" placeholder="<spring:message code="message.model.peiSongQiYe"/><spring:message code="message.listForm.mingCheng"/>" />
                    </div>
                      <button   id="selectWSJ"   type="button" class="btn btn-success btn-sm" ><spring:message code="message.button.seachSpacing"/></button>
                </div>
            </div>
         </div>
         
            	<table class="jqgrid" id="firstGridlist"></table> 
                <div  id="gridpage"></div>       
    </section>
	<%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">
    
  //加载页面光标在名字框内，位于第一个
    $("#compName").focus();
    
  //绑定回车    id="selectWSJ"  
    $('#compName').bind('keydown', function(event) {
        if (event.keyCode == "13") {        //13 位电脑上回车键的位置代码
            $('#selectWSJ').click();
        }
    }); 
    
    $(function(){
		$("#firstGridlist").jqGrid(
				{   url : "getPaymentByNoCompList.html",
					mtype : "POST",
					datatype : "json",
					height :355,
					colNames : [
					            '<spring:message code="message.jqGrid.cz"/>',
					            '<spring:message code="message.model.peiSongQiYe"/>ID',
					            '<spring:message code="message.model.peiSongQiYe"/><spring:message code="message.yanZheng.bianMa"/>',
					            '<spring:message code="message.model.peiSongQiYe"/><spring:message code="message.listForm.mingCheng"/>',
					            '<spring:message code="message.model.peiSongQiYe"/><spring:message code="message.listForm.diQu"/>',
					            '<spring:message code="message.jieSuan.yiLiaoJiGouShu"/>',
					            '<spring:message code="message.jieSuan.peiSongZongJinE"/>'
					            ],
					colModel : [
                                {name : 'operate',index : 'operate', width : 100,align : "center",sortable:false,
	                                  formatter:function(cellvalue, options, row){
		                              return "<a href='javascript:toPay(\""+row.paymentBillId+"\",\""+row.compId+"\");' style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -180px -40px' class='opIcon' title='<spring:message code="message.jieSuan.zhiFu"/>'></a>";
	                                   }
                                },
								{name : 'compId',index : 'settlementId', hidden : true,width : 160,align : "center",sortable:false},
								{name : 'compCode',index : 'settlementCode', width : 160,align : "center",sortable:false},
								{name : 'compName',index : 'settlementName', width : 160,align : "center",sortable:false,
									 formatter:function(cellvalue, options,row) {
										 if(cellvalue!=null){
											 return "<a href=\"javascript:$.HN.dialog.opendialog('"+row.compId+"','"+cellvalue+"','${ctx}/stdCompinfo/toStdCompinfoDetail.html?compId="+row.compId+"','800px','400px',function operResult(val){return operResult;})\">"+cellvalue+"</a>";
										 }else{
											 return "";
										 }
									}
								},
								{name : 'areaName',index : 'heaBurCode', width : 160,align : "center",sortable:false},
								{name : 'totalOrders',index : 'heaBurName', width : 160,align : "center",sortable:false,
									formatter:function(cellvalue, options, row){
										return "<a href='${ctx}/centerCheckPayment/toHospByNoComp.html?compId="+row.compId+" '>"+cellvalue+"</a>";
									}
								},
								{name : 'totalAmount',index : 'areaName', width : 100,align : "center",sortable:false,
									formatter:function(cellvalue, options, row){
										return formatAmount(cellvalue, options, row);
									}
								}
								
					],
					rownumbers : true,
					pager : "#gridpage",
					viewrecords : true,
					caption : "<spring:message code="message.jieSuan.anPeiSongQiYeFenZu"/><spring:message code="message.listForm.lieBiao"/>",
					//序号宽度自动变化
	                gridComplete:function(){
	                    //序号列宽度自适应（参数为jqgridID）
	                    autoRNWidth("firstGridlist");
	                    //数据只有一条时默认选中（参数为jqgridID）
	                    selectByOneData("firstGridlist");
	                },
					jsonReader : {
						repeatitems : false,
						id : "ids"
					}
				});
		$("#firstGridlist").jqGrid('navGrid', '#gridpage', {add : false,edit : false,del : false,search : false,refresh : false});
		$(window).trigger("resize");
		
		   /*按条件查询*/
		   $('.btn-success').click(function(){
			   var postJson = {compName:$('#compName').val()};
		                $("#firstGridlist").jqGrid("clearGridData");
		                $("#firstGridlist").jqGrid('setGridParam',{  
		                postData:postJson,
		                page : 1
		            }).trigger("reloadGrid"); 
		   });
    });
    
    function toPay(paymentBillId,delCompId){
   	 $.HN.message.confirm('<spring:message code="message.jieSuan.queDingZhiFuMa"/>', '', '').on(function (e) {
            if (e) {
             $.post('${ctx}/payment/confirmPay.html', {paymentBillId:paymentBillId,delCompId:delCompId}, 
            		 function (result) {
		         			if (result.success) {
		    					$.HN.message.alert(result.msg, "<spring:message code="message.HN.alert.type"/>", "success", function() {
		    						 $("#secondGridlist").trigger("reloadGrid"); 
		    					});
		    				} else {
		    					$.HN.message.alert(result.msg || "<spring:message code="message.HN.alert.fail"/>", "<spring:message code="message.HN.alert.type"/>", "error");
		    				}
    		}, "json");
            }
	     });
   }
    function CurentTime(now)  
	{
	    var year = now.getFullYear();   
	    var month = now.getMonth() + 1; 
	    var day = now.getDate();     
	    var hh = now.getHours();       
	    var mm = now.getMinutes(); 
	    var ss=now.getSeconds(); 
	    var clock = year + "-"; 
	    if(month < 10) clock += "0";         
	    clock += month + "-";  
	    if(day < 10) clock += "0";   
	    clock += day + " "; 		
	    return(clock);   
	}
 </script>
</body>
</html>